home *** CD-ROM | disk | FTP | other *** search
Wrap
property appearWhen, slideDuration, direction, spriteNum, mySprite, myStartFrame, myEndFrame, myOriginalMember, myOriginalImage, myTransitionMember on beginSprite me me.convertAppearance() me.convertDirection() mySprite = sprite(spriteNum) myOriginalMember = mySprite.member myOriginalImage = image(myOriginalMember.width, myOriginalMember.height, 32) case myOriginalMember.type of #bitmap: myOriginalImage = myOriginalMember.image if not myOriginalMember.useAlpha then myOriginalImage.setAlpha(255) end if #text, #vectorShape, #flash: if myOriginalMember.type = #text then mySprite.rect = mySprite.rect end if if mySprite.ink = 0 then case myOriginalMember.type of #text, #flash: myOriginalImage.fill(myOriginalImage.rect, myOriginalMember.bgColor) #vectorShape: myOriginalImage.fill(myOriginalImage.rect, myOriginalMember.backgroundColor) end case myOriginalImage.copyPixels(myOriginalMember.image, myOriginalMember.rect, myOriginalImage.rect, [#maskImage: myOriginalMember.image.extractAlpha()]) else myOriginalImage = myOriginalMember.image end if end case case appearWhen of #start: myStartFrame = mySprite.startFrame myEndFrame = myStartFrame + slideDuration - 1 #end: myEndFrame = mySprite.endFrame myStartFrame = myEndFrame - slideDuration + 1 end case myTransitionMember = new(#bitmap, castLib(mySprite.castLibNum)) myTransitionMember.image = image(myOriginalMember.width, myOriginalMember.height, 32, 8) myTransitionMember.regPoint = myOriginalMember.regPoint myTransitionMember.useAlpha = 1 end on endSprite me mySprite.member = myOriginalMember erase(myTransitionMember) end on prepareFrame me if (the frame >= myStartFrame) and (the frame <= myEndFrame) then elapsedFrames = the frame - myStartFrame + 1 if appearWhen = #end then elapsedFrames = slideDuration - elapsedFrames end if memberRect = myTransitionMember.rect case direction of #lefttoright, #righttoleft: imageRect = memberRect * rect(1, 1, elapsedFrames, 1) / rect(1, 1, slideDuration, 1) #bottomtotop, #toptobottom: imageRect = memberRect * rect(1, 1, 1, elapsedFrames) / rect(1, 1, 1, slideDuration) otherwise: imageRect = memberRect * rect(1, 1, elapsedFrames, elapsedFrames) / rect(1, 1, slideDuration, slideDuration) end case destRect = imageRect case appearWhen of #start: case direction of #lefttoright: imageRect = offset(imageRect, memberRect.width - imageRect.width, 0) #righttoleft: destRect = offset(destRect, memberRect.width - imageRect.width, 0) #toptobottom: imageRect = offset(imageRect, 0, memberRect.height - imageRect.height) #bottomtotop: destRect = offset(destRect, 0, memberRect.height - imageRect.height) #bottomrighttotopleft: destRect = offset(destRect, memberRect.width - imageRect.width, memberRect.height - imageRect.height) #bottomlefttotopright: imageRect = offset(imageRect, memberRect.width - imageRect.width, 0) destRect = offset(destRect, 0, memberRect.height - imageRect.height) #toprighttobottomleft: imageRect = offset(imageRect, memberRect.width - imageRect.width, memberRect.height - imageRect.height) #toplefttobottomright: destRect = offset(imageRect, memberRect.width - imageRect.width, 0) imageRect = offset(imageRect, 0, memberRect.height - imageRect.height) end case #end: case direction of #righttoleft: imageRect = offset(imageRect, memberRect.width - imageRect.width, 0) #lefttoright: destRect = offset(destRect, memberRect.width - imageRect.width, 0) #bottomtotop: imageRect = offset(imageRect, 0, memberRect.height - imageRect.height) #toptobottom: destRect = offset(destRect, 0, memberRect.height - imageRect.height) #toprighttobottomleft: destRect = offset(destRect, memberRect.width - imageRect.width, memberRect.height - imageRect.height) #toplefttobottomright: imageRect = offset(imageRect, memberRect.width - imageRect.width, 0) destRect = offset(destRect, 0, memberRect.height - imageRect.height) #bottomrighttotopleft: imageRect = offset(imageRect, memberRect.width - imageRect.width, memberRect.height - imageRect.height) #bottomlefttotopright: destRect = offset(imageRect, memberRect.width - imageRect.width, 0) imageRect = offset(imageRect, 0, memberRect.height - imageRect.height) end case end case myTransitionMember.image.setAlpha(0) myTransitionMember.image.copyPixels(myOriginalImage, destRect, imageRect) myTransitionMember.image.useAlpha = 1 mySprite.member = myTransitionMember else mySprite.member = myOriginalMember end if end on convertAppearance me case appearWhen of "beginning of sprite": appearWhen = #start "end of sprite": appearWhen = #end end case end on convertDirection me case direction of "left to right": direction = #lefttoright "right to left": direction = #righttoleft "bottom to top": direction = #bottomtotop "top to bottom": direction = #toptobottom "bottom left to top right": direction = #bottomlefttotopright "bottom right to top left": direction = #bottomrighttotopleft "top right to bottom left": direction = #toprighttobottomleft "top left to bottom right": direction = #toplefttobottomright end case end on isOKToAttach me, aSpriteType, aSpriteNum isOK = 0 case aSpriteType of #graphic: case sprite(aSpriteNum).member.type of #bitmap, #text, #flash, #vectorShape: isOK = 1 end case end case return isOK end on getPropertyDescriptionList me props = [:] props[#appearWhen] = [#comment: "When transition appears:", #format: #string, #default: "beginning of sprite", #range: ["beginning of sprite", "end of sprite"]] firstFrame = sprite(the currentSpriteNum).startFrame endFrame = sprite(the currentSpriteNum).endFrame maxLength = endFrame - firstFrame + 1 props[#slideDuration] = [#comment: "Duration:", #format: #integer, #default: min(maxLength, 10), #range: [#min: 1, #max: maxLength]] props[#direction] = [#comment: "Direction:", #format: #string, #default: "left to right", #range: ["left to right", "right to left", "bottom to top", "top to bottom", "bottom left to top right", "bottom right to top left", "top right to bottom left", "top left to bottom right"]] return props end on getBehaviorTooltip return "Use this behavior to make a sprite slide onto (or off of) the Stage from under the background." end on getBehaviorDescription return "SLIDE TRANSITION" & RETURN & RETURN & "Drop this behavior onto a sprite to create an animation of the sprite sliding under the background image. " & "The transition can make the sprite slide out from under the background, or slide under the background from its fully-revealed position. " & "Maintains alpha channel masks for 32-bit bitmaps." & RETURN & RETURN & "Select when the transition will take effect. " & "The duration controls the number of frames over which the transition occurs. " & "Direction controls the movement of the sprite." & RETURN & RETURN & "When this transition is used during authoring, and the movie is stopped the cast member it uses for the transition effect may not be erased." & RETURN & RETURN & "PERMITTED MEMBER TYPES:" & RETURN & "bitmaps and text" & RETURN & RETURN & "PARAMETERS:" & RETURN & "* When transition appears - controls whether sprite moves on or off the stage" & RETURN & "* Duration - number of frames for the transition to take place" & RETURN & "* Direction - movement of sprite onto or off of the stage" end